package com.example.win.android_banduyujia.peopleactivity.activity.activity.openactivity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.win.android_banduyujia.R;
import com.example.win.android_banduyujia.entity.CerBookEntity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Win on 2015/10/15.
 */
public class ListBookAdapter extends BaseAdapter {

    private ArrayList<CerBookEntity> List;
    private LayoutInflater   inflater;

    public ListBookAdapter(Context context, ArrayList<CerBookEntity>  ItemList) {
         this.List = ItemList;
         inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        if(null != List){
            return  List.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int position) {
        if(null != List){
            return  List.get(position);
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view =null;
        ViewHolder  holder = null;
        if(convertView == null){
            view = inflater.inflate(R.layout.list_book_item, null);
            holder = new ViewHolder();
            view.setTag(holder);
        }else{
            view = convertView;
            holder = (ViewHolder) view.getTag();
        }
        return view;
    }

    private class  ViewHolder{
           TextView  mTextBook;
    }
}
